<%@ page import="com.csnf.student.entity.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: csnf
  Date: 2024/12/16
  Time: 16:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>学生列表分页展示</title>
</head>
<body>
<h2>学生列表</h2>
<table border="1">
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>年龄</th>
    </tr>
    <%
        List<Student> studentList = (List<Student>)
                request.getAttribute("studentList");
        if (studentList!= null &&!studentList.isEmpty()) {
            for (Student student : studentList) {
    %>
    <tr>
        <td><%=student.getId()%></td>
        <td><%=student.getName()%></td>
        <td><%=student.getAge()%></td>
    </tr>
    <%
            }
        }
    %>
</table>
<div>
    当前第 <%=request.getAttribute("pageNum")%> 页，共
    <%=request.getAttribute("totalPages")%> 页
    <%
        int pageNum = (int) request.getAttribute("pageNum");
        if (pageNum > 1) {
    %>
    <a href="student?pageNum=<%=pageNum - 1%>">上一页</a>
    <%
        }
        if (pageNum < (int) request.getAttribute("totalPages")) {
    %>
    <a href="student?pageNum=<%=pageNum + 1%>">下一页</a>
    <%
        }
    %>
</div>
</body>
</html>
